<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../static/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../static/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label required">接头ID</label>
        <div class="layui-input-block">
            <input type="text" name="bindJointid" lay-verify="required" lay-reqtext="接头ID不能为空" placeholder="" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">球机ID</label>
        <div class="layui-input-block">
            <input type="text" name="cameraId" lay-verify="required" lay-reqtext="球机ID不能为空" placeholder="" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">球机名称</label>
        <div class="layui-input-block">
            <input type="text" name="cameraName" lay-verify="required" lay-reqtext="球机名称不能为空" placeholder="" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">IP</label>
        <div class="layui-input-block">
            <input type="text" name="ip" lay-verify="required" lay-reqtext="IP不能为空" placeholder="" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">端口</label>
        <div class="layui-input-block">
            <input type="text" name="port" lay-verify="required" lay-reqtext="端口不能为空" placeholder="" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">用户名</label>
        <div class="layui-input-block">
            <input type="text" name="username" lay-verify="required" lay-reqtext="用户名不能为空" placeholder="" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">密码</label>
        <div class="layui-input-block">
            <input type="text" name="password" lay-verify="required" lay-reqtext="密码不能为空" placeholder="" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">是否自动</label>
        <div class="layui-input-block">
            <input type="radio" name="enable" value="0" title="自动" checked="">
            <input type="radio" name="enable" value="1" title="手动">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
<script src="../../static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            $.ajax({
                url:  "/camera/add",    //请求的url地址
                dataType: "json",   //返回格式为json
                async: true,//请求是否异步，默认为异步，这也是ajax重要特性
                data: data.field,    //参数值,键值对
                type: "POST",   //请求方式
                success: function (result) {
                    if (result.code == 0) {
                        var iframeIndex = parent.layer.getFrameIndex(window.name);
                        parent.layui.table.reload('currentTableId');
                        parent.layer.close(iframeIndex);
                    }else {
                        layer.msg(result.msg);
                    }
                },
                error: function () {
                    return false;
                }
            });
        });

    });
</script>
</body>
</html>